package logx

import (
	"github.com/sirupsen/logrus"
	"os"
)

var logger   *logrus.Logger = defaultLogger()

func defaultLogger() *logrus.Logger  {
	logger := logrus.New()
	logger.SetLevel(logrus.DebugLevel)

	logger.SetOutput(os.Stdout)

	logger.SetFormatter(&logrus.JSONFormatter{
		TimestampFormat: "2006-01-02 15:04:05",
	})
	return logger
}

func Debug(v ...interface{}) {
	logger.Debugln(v...)
}


func Info(v ...interface{}) {
	logger.Infoln(v...)
}


func Warn(v ...interface{}) {
	logger.Warnln(v...)
}

func Error(v ...interface{}) {
	logger.Errorln(v... )
}

func ErrorWithStack(err error) {
	logger.Errorf("%+v\n", err )
}


func Fatal(v ...interface{}) {
	logger.Fatalln(v...)
}


func Debugf(format string, v ...interface{}) {
	logger.Debugf(format,v...)
}


func Infof(format string, v ...interface{}) {
	logger.Infof(format, v...)
}


func Warnf(format string, v ...interface{}) {
	logger.Warnf(format, v...)
}

func Errorf(format string, v ...interface{}) {
	logger.Errorf(format, v...)
}


func Fatalf(format string, v ...interface{}) {
	logger.Fatalf(format, v...)
}
func WithField(key string, value interface{}) *logrus.Entry{
	return logger.WithField(key,value)
}
func WithFields(fields map[string]interface{}) *logrus.Entry {
	return logger.WithFields(fields)
}


func GetLogger() *logrus.Logger {
	return logger
}
